package com.wang.pojo;

/**
 * Created by wangq on 2021/7/11.
 */
public class Account {
    private long id;

    private String userName; // 用户名

    private String cardNo; // 卡号

    private double money; // 余额

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public double getMoney() {
        return money;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    public void decreaseMoney(double transferAmount) throws Exception {
        if (transferAmount <= this.money) {
            this.money -= transferAmount;
        } else {
            throw new Exception("余额不足");
        }
    }

    public void addMoney(double transferAmount) {
        this.money += transferAmount;
    }
}
